<template>
	<div>
		<div>
			{{ username}}
		</div>

           

      	

		<!--头部开始-->
		<!-- <myheader /> -->
		<!--头部结束-->

		<!--表单区域-->

		<div class="udlite-container partners">

		<van-cell-group>

			<van-tabs v-model="active">

			
			<van-tab title="用户名登录" >
			<van-field v-model="username" label="用户名" placeholder="请输入用户名"  />
			</van-tab>

			<van-tab title="手机号登录" >
			<van-field v-model="phone" label="手机号" placeholder="请输入手机号"  />
			</van-tab>

			</van-tabs>

			<van-field v-model="password" type="password" label="密 码" placeholder="请输入密码"  />




			<van-button type="primary" @click="login" >登 录</van-button>

			<van-button type="info" >重 置</van-button>
			
			<p> <button @click="gitee()">gitee登录</button> <button @click="ding">钉钉三方登录</button></p>
			

		</van-cell-group>

		</div>

		<!--表单区域-->


	</div>
</template>

<script type="text/javascript">

// import myheader from './myheader.vue'

import dragVerify from 'vue-drag-verify'

	export default{

		data(){

			return{

				username:"",
				password:"",
				password1:"",
				active: 0,
				phone:"",
				width:320,
				height:42,
				text:"请您拖动滑块",
				code:"",
				src:'http://localhost:8000/mycode/',
				fileList:[],
			}

		},
		//声名组件
		components:{

			// 'myheader':myheader,
			'dragVerify':dragVerify

		},
		mounted:function(){

		

		},
		//自定义方法
		methods:{
			login(){
					//请求后端接口
				this.$axios.post('http://localhost:8000/login/',{'username':this.username,'password':this.password}).then((res) =>{

					console.log(res);

					if(res.data.code == 10000){

						this.$toast("登录成功");

						sessionStorage.setItem("uid",res.data.uid);
						sessionStorage.setItem('username',res.data.username)


						//跳转
						this.$router.push("/myback");

					}else{
						this.$toast(res.data.message);
					}

				});




				// if(this.username == ""){

				// 	this.$toast("请填写用户名");
				// 	return false;
				// }

				
				
			},
			gitee(){
    		//创建应用后生成的Cliend ID
    		var clientId = 'e51974c3f1089244be4b8a1001f24142ff55076cc7af2744438e02e3bfb75930'
    		//应用回调地址
   			 var redirect_uri = 'http://127.0.0.1:8000/gitee_back'
   			 //拼接要请求的地址
  			  var url = 'https://gitee.com/oauth/authorize?client_id='+clientId+'&redirect_uri='+redirect_uri+'&response_type=code'
   			 // 进行跳转
   			 window.location.href = url;
			},
			ding() {
      		//拼接钉钉url
      		var url = "https://oapi.dingtalk.com/connect/qrconnect?appid=dingoausbsbnopkbfhhqvt&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=http://127.0.0.1:8000/dingding_back"
      		//进行站外跳转
      		window.location.href = url;
  			}
		},
		created() {
			sessionStorage.setItem('username',this.$route.query.username)
   	 	var usernames = this.$route.query.username
    	if(usernames!=undefined){
      this.username = '欢迎你,'+ usernames
    }
  }


	};
	


</script>

<style type="text/css">


img{

	cursor:pointer;
}
	

</style>